package com.sanglh.tutorial.asynctask;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.sanglh.tutorial.R;
import com.sanglh.tutorial.common.base.BaseListAdapter;

public class AsyncAdapter<T> extends BaseListAdapter<T> {

	public AsyncAdapter(Context context, ArrayList<T> entries, int resId) {
		super(context, entries, resId);
	}

	public AsyncAdapter(Context context, ArrayList<T> entries) {
		super(context, entries);
	}


	@Override
	public Object getHolder() {
		return new Holder();
	}

	@Override
	public void findViewId(Object holder, View convertView) {
		((Holder) holder).imgIcon = (ImageView) convertView
				.findViewById(R.id.imgIcon);
	}

	@Override
	public void setViewResource(Object holder, T entry) {
		((Holder) holder).imgIcon.setImageDrawable(((AsyncEntry)entry).icon);
	}

	static class Holder extends BaseListAdapter.Holder {
		public ImageView imgIcon;
	}
	
}
